home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / CBRECNEX.C < prev    next >
Text File  |  1991-09-23  |  2KB  |  79 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbrecnex.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10.  
  11. /* library headers */
  12. #include <lseq.h>
  13.  
  14. /* local headers */
  15. #include "cbase_.h"
  16.  
  17. /*man---------------------------------------------------------------------------
  18. NAME
  19.      cbrecnext - next cbase record
  20.  
  21. SYNOPSIS
  22.      #include <cbase.h>
  23.  
  24.      int cbrecnext(cbp)
  25.      cbase_t *cbp;
  26.  
  27. DESCRIPTION
  28.      The cbrecnext function advances the record cursor of cbase cbp to
  29.      the next record.  If the cursor is on the last record, it is
  30.      advanced to null.
  31.  
  32.      cbrecnext will fail if one or more of the following is true:
  33.  
  34.      [EINVAL]       cbp is not a valid cbase pointer.
  35.      [CBELOCK]      cbp is not locked.
  36.      [CBENOPEN]     cbp is not open.
  37.  
  38. SEE ALSO
  39.      cbrcursor, cbrecfirst, cbreclast, cbrecprev.
  40.  
  41. DIAGNOSTICS
  42.      Upon successful completion, a value of 0 is returned.  Otherwise,
  43.      a value of -1 is returned, and errno set to indicate the error.
  44.  
  45. ------------------------------------------------------------------------------*/
  46. #ifdef AC_PROTO
  47. int cbrecnext(cbase_t *cbp)
  48. #else
  49. int cbrecnext(cbp)
  50. cbase_t *cbp;
  51. #endif
  52. {
  53.     /* validate arguments */
  54.     if (!cb_valid(cbp)) {
  55.         errno = EINVAL;
  56.         return -1;
  57.     }
  58.  
  59.     /* check if not open */
  60.     if (!(cbp->flags & CBOPEN)) {
  61.         errno = CBENOPEN;
  62.         return -1;
  63.     }
  64.  
  65.     /* check if not locked */
  66.     if (!(cbp->flags & CBLOCKS)) {
  67.         errno = CBELOCK;
  68.         return -1;
  69.     }
  70.  
  71.     /* advance cursor to next record */
  72.     if (lsnext(cbp->lsp) == -1) {
  73.         CBEPRINT;
  74.         return -1;
  75.     }
  76.  
  77.     return 0;
  78. }
  79.